<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品库存列表</title>

<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="${Plugins}/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/jquery/jquery-1.3.2.min.js"	type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script type="text/javascript" src="${BasePath}/res/js/ligerCommon.js"></script>

<style type="text/css">
#searchbar{
   margin-bottom: 10px;
   margin-left:15px;
  }
  .navbar {
		height: 20px;
		border-bottom: #E6E6E6 solid 1px;
		line-height: 20px;
	}
.l-button-search {
	width: 50px;
	margin-left: 10px;
	padding-bottom: 2px;
	display: inline;
}
</style>
</head>

<body style="padding:6px; overflow:hidden;">
<div class="navbar">
		<span>您当前的位置：</span>
		商品管理 &gt; 商品库存列表
</div>

<form action="#" method="post" >
<div id="searchbar">
仓库：<select name="warehouseCode"  id="warehouseCode" class="l-textarea" >
						<option value="">请选择</option>
						<c:forEach items="${whareHouses }" var="wharehouse">
							<option value="${wharehouse.whNo }" <c:if test='${wharehouse.whNo==productInventory.warehouseCode}'>selected="selected"</c:if> >${wharehouse.whName
								}</option>
						</c:forEach>
				</select>&nbsp;&nbsp;
货品编号：<input type="text" id="prodNo" name="prodNo" value="${productInventory.prodNo}">&nbsp;&nbsp;
商品名称：<input type="text" id="commoName" name="commoName" value="${productInventory.commoName}" />
         <input type="submit" id="btnSearch" value="查询" class="l-button-search" />
           <input type="button" id="btnReset" value="重置" class="l-button-search" />
</div>

</form>
<div id="maingrid" style="margin:0; padding:0"></div>
  <div style="display:none;">
  <!-- 展示列表数据  -->
</div>

	<script type="text/javascript">
    var basePath='${BasePath}';
    var grid = null;
	
    $(function () {
    	 // 重置
        $("#btnReset").click(function(){
    		$('#searchbar :input').not(':submit, :button, :reset').val('').removeAttr('checked').removeAttr('selected');
    	});
    	
        grid = $("#maingrid").ligerGrid({
            columns: [
			{ display: '仓库编码',name:'warehouseCode'},
            { display: '仓库名称',name:'warehouseName'},
            { display: '商品名称', name: 'commoName'},
            { display: '商品类别',name:'catName'},
            { display: '商品规格',name:'specName'},
            { display: '货品编号', name: 'prodNo'},
            { display: '货品条码', name: 'prodBarCode'},
            { display: '商品单位', name: 'prodUnit'},
            { display: '销售类型', name: 'saleType'},
            { display: '库存类型', name: 'inventoryType'},
            { display: '箱包装规格', name: 'specification'},
            { display: '库存数量', name: 'quantity'},
            { display: '不含税结存单价',name:'unitPrice'},
            { display: '不含税结存金额', name: 'totalUntaxPrice'},
            { display: '税率(%)', name: 'prodRate'},
            { display: '单位税金', name: 'unitCostPrice'},
            { display: '总税金', name: 'totalCostPrice'},
            { display: '含税结存单价', name: 'taxCostPrice'},
            { display: '含税结存金额', name: 'totalTaxPrice'}
            ], 
            pageSize:30,
            width: '100%',
            height: '100%',
            columnWidth:'10%',
            dataType: 'server', 
            dataAction: 'server',
            pagesizeParmName: 'pageSize',
            parms: [
                    {name:"warehouseCode",value:$("#warehouseCode").val()},
					{name: "prodNo", value:$("#prodNo").val()},
					{name: "commoName", value:$("#commoName").val()}
                    ],
			url: "list_commodity_inventory.do",
			toolbar: toolbar
        });
    });
    
    var toolbar;
    var roles = new Array();
    '<c:forEach items="${roleVos}" var="item">';
    roles.push('${item.roleCode}');
    '</c:forEach>';
    var rpm = 0;
	if (roles.length > 0) {
		var ex = [];
		var add = [];
		var items = [];
		for(var i=0; i<roles.length; i++) {
    		if (roles[i] == 'FINANCIAL_PRINCIPAL') {
    			ex = [{text: '导出EXCEL', click: doExportExcel, icon: "print"},{ line: true }];
    		}
    	}
		items = items.concat(ex);
		toolbar = {items : items};
	}
    
    function doExportExcel() {
		var warehouseCode = encodeURI(encodeURI($('#warehouseCode').val()));
		var prodNo = encodeURI(encodeURI($('#prodNo').val()));
		var commoName = encodeURI(encodeURI($('#commoName').val()));
		
		if(warehouseCode==""&&prodNo==""&&commoName==""){
			$.ligerDialog.warn("选先输入查询条件再导出数据!");
			return;
		}
		var params = '?warehouseCode=' + warehouseCode + '&prodNo=' + prodNo + '&commoName=' + commoName ;
		window.location.href = 'doExportExcel.do' + params;
	}
   
    </script>
	
</body>
</html>